package com.dbapp.imglib;

import android.content.Context;
import android.widget.Toast;
import com.dbapp.imglib.camer.JZCameraActivity;
import com.dbapp.imglib.crop.CropActivity;
import com.dbapp.imglib.imageloader.JZSelectLocalPicsActivity;
import com.dbapp.imglib.imageloader.SelectLocalPicActivity;
import com.dbapp.imglib.inter.ImagMangeInter;
import com.dbapp.imglib.inter.OnPicCropListener;
import com.dbapp.imglib.inter.OnPicsPickListener;
import com.dbapp.imglib.inter.OnTakeCameraListener;

/**
 * Created by Arirus on 2017/8/2.
 */

public class ImgManager implements ImagMangeInter {

  public static synchronized ImagMangeInter getInstance() {
    return SingletonHolder.sInstance;
  }

  private static class SingletonHolder {
    private static final ImagMangeInter sInstance = new ImgManager();
  }

  @Override public void takePhoto(Context context, String imgPath,
      OnTakeCameraListener listener) {
    if (imgPath == null) {
      Toast.makeText(context, "传递路径不能为空 ", Toast.LENGTH_SHORT).show();

      return;
    }
    JZCameraActivity.start(context, imgPath, listener);
  }

  @Override public void getLocalPics(Context context,
      OnPicsPickListener listener) {
    JZSelectLocalPicsActivity.start(context, listener);
  }

  @Override
  public void cropPic(Context context, String picPath, OnPicCropListener listener) {
    if (picPath == null) {
      Toast.makeText(context, "传递路径不能为空 ", Toast.LENGTH_SHORT).show();
      return;
    }
    CropActivity.start(context, picPath, listener);
  }

  @Override
  public void getLocalPic(Context context, SelectLocalPicActivity.OnPicPickListener listener) {
    SelectLocalPicActivity.start(context, listener);
  }
}
